#include <PopupDefaultLogger.hpp>
#include <PopupQSqliteDatabase.hpp>
#include <string>

using namespace Popup;
using namespace std;

int main(int argc, char *argv[])
{
  PopupDefaultLogger logger;

  if (argc <= 1) {
    logger.appendLog(POPUP_LOG_ERROR, "Usage: %s <file.db>\n", argv[0]);
  } else {
    PopupQSqliteDatabase database(string(argv[1]), &logger);
    string message;
    PopupDatabaseUser *user = database.connect("guigui", "bonjour", &message);
    if (user != 0) {
      logger.appendLog(POPUP_LOG_INFO, "Success : user name=%s id = %u\n",
		       user->getLogin().c_str(), user->getID());
    } else {
      logger.appendLog(POPUP_LOG_ERROR, "Failed : %s\n", message.c_str());
    }
  }
  return 0;
}
